<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      #title {
        margin: 50px auto;
        overflow: hidden;
        width: 900px;
        height: 50px;
        list-style: none;
      }

      #title > li {
        float: left;
        width: 300px;
        height: 50px;
        background-color: blue;
        text-align: center;
        font-size: 30px;
        line-height: 50px;
        cursor: pointer;
      }

      #content {
        width: 900px;
        margin: 50px auto;
        font-size: 50px;

        list-style: none;
      }

      #content > li {
        text-align: center;
        line-height: 400px;
        font-weight: 800;
      }

      #content > li:first-child {
        background-color: blueviolet;
      }

      #content > li:nth-of-type(2) {
        background-color: yellow;
      }

      #content > li:last-child {
        background-color: pink;
      }

      .licolor {
        background-color: greenyellow !important;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <ul id="title">
        <li
          v-for="(item,index) in a"
          :key="item.id"
          @click="changecolor(index)"
          :class="licolor===index? 'licolor':''"
        >
          {{item.title}}
        </li>
      </ul>
      <ul id="content">
        <li v-for="(item,index) in a" :key="item.id" v-show="index===licolor">
          {{item.content}}
        </li>
      </ul>
    </div>
  </body>
  <script>
    const vm = new Vue({
      el: "#app",
      data: {
        licolor: 0,
        a: [
          { id: 0, title: "标题1", content: "内容1" },
          { id: 1, title: "标题2", content: "内容2" },
          { id: 2, title: "标题3", content: "内容3" },
        ],
      },
      methods: {
        changecolor(n) {
          this.licolor = n;
        },
      },
    });
  </script>
</html>
